﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Dapper_Core.BLL.Impl;
using Dapper_Core.Common;
using Microsoft.AspNetCore.Mvc;

namespace Dapper_Core.Web.Areas.Sys.Controllers
{
    public class Sys_User_RoleController : Controller
    {
        public IActionResult UpdateRelation(string addRoleCodes, string deleteRoleCodes, string userCode)
        {
            try
            {
                bool success = new Sys_User_RoleBusiness().UpdateRelation(addRoleCodes, deleteRoleCodes, userCode, SessionUtility.GetBasicUserInfo().UserName);
                if (success)
                {
                    return Json(new { Success = true, Message = "保存成功！" });
                }
                return Json(new { Success = false, Message = "保存失败，请联系管理员！" });
            }
            catch (Exception ex)
            {
                NlogUtility.WriteError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName, "更新“角色 - 系统资源”对应关系失败", "addRoleCodes=" + addRoleCodes + "，deleteRoleCodes=" + deleteRoleCodes + "，userCode=" + userCode, ex, "DapperCore");
                return Json(new { Success = false, Message = "保存失败，请联系管理员！" });
            }
        }
    }
}